/** * 用例基础信息 */
<template>
  <div>
    <p class="tip">基础信息</p>
    <el-row :gutter="40">
      <el-col :span="8">
        <el-form-item label="用例名称" prop="name">
          <el-input
            size="small"
            v-model="caseForm.name"
            placeholder="请输入用例名称"
          />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="用例类型" prop="type">
          <el-select
            size="small"
            style="width: 100%"
            v-model="caseForm.type"
            disabled
            placeholder="请选择用例类型"
          >
            <el-option
              v-for="item in caseTypes"
              :key="item"
              :label="item"
              :value="item"
            />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col v-if="caseForm.type === 'APP'" :span="10">
        <el-form-item label="操作系统">
          <el-select
            size="small"
            style="width: 100%"
            v-model="caseForm.system"
            disabled
            placeholder="请选择操作系统"
          >
            <el-option
              v-for="item in systems"
              :key="item"
              :label="item"
              :value="item"
            />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col v-else :span="10">
        <el-form-item label="环境标签">
          <el-select
            size="small"
            style="width: 100%"
            v-model="caseForm.environmentIds"
            multiple
            filterable
            clearable
            placeholder="请选择环境标签"
          >
            <el-option
              v-for="item in environments"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="40">
      <el-col :span="8">
        <el-form-item label="用例等级">
          <el-select
            size="small"
            style="width: 100%"
            v-model="caseForm.level"
            placeholder="请选择用例等级"
          >
            <el-option
              v-for="item in levels"
              :key="item"
              :label="item"
              :value="item"
            />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="10">
        <el-form-item label="模块分类" prop="moduleId">
          <select-tree
            placeholder="请选择模块分类"
            :selectedValue="caseForm.moduleId"
            :selectedLabel="caseForm.moduleName"
            :treeData="modules"
            @selectModule="selectModule($event)"
          />
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="40">
      <el-col :span="24">
        <el-form-item label="用例描述">
          <el-input
            size="small"
            :autosize="{ minRows: 3 }"
            type="textarea"
            clearable
            placeholder="请输入用例描述"
            v-model="caseForm.description"
            maxlength="200"
            show-word-limit
          />
        </el-form-item>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import SelectTree from "../../../common/business/selectTree";

export default {
  name: "BaseInfo",
  components: {
    SelectTree,
  },
  props: {
    caseForm: Object,
    applications: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  data() {
    return {
      levels: ["P0", "P1", "P2", "P3"],
      caseTypes: ["API"],
      modules: [],
      headers: [],
      proxys: [],
      environments: [],
      systems: ["android", "apple"],
      functionList: [],
      paramList: [],
    };
  },
  created() {
    this.getModule();
  },
  methods: {
    getModule() {
      let url = "/nore/autotest/module/list/case/" + this.$store.state.projectId;
      this.$get(url, (response) => {
        this.modules = response.data;
      });
    },
    selectModule(data) {
      this.caseForm.moduleId = data.id;
      this.caseForm.moduleName = data.label;
    },
  },
};
</script>
<style scoped></style>
